<?php
 require_once("../core.php");

 @get_all_variables();
 $db = dbconnect();

  $q = "SELECT *
       FROM `clients`
       WHERE id = $id";

  $r = mysql_query($q, $db) or die(mysql_error());
  $w = mysql_fetch_array($r);

function testsByProblemId($res, $id) {
  $db = dbconnect();
  $q = "SELECT *
        FROM `submits`
        WHERE (result=\"$res\")AND(client_id=".$id.")
        ORDER BY `id` DESC";

  $r = mysql_query($q, $db) or die (mysql_error());
  $n = 0;
  @$n = mysql_num_rows($r);
  if ($n == 0) {
      return 0;
  } else
  {
      return $n;
  }
 }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/yahoo_reset.css" rel="stylesheet" type="text/css" />


<body>
  <span style="font-size: 24px;"><?echo $w['title']; ?></span>
  <br/><br/>
  <table id="ctable" border="1" width="100%" cellpadding="2" cellspacing="4">
      <tbody>
          <tr>
              <td width="280" style="padding-left:5px;"><b>Accepted: </b></td>
              <td style="padding-left:5px;"><? echo testsByProblemId("Accepted", $id); ?> </td>
          </tr>
          <tr>
              <td style="padding-left:5px;"><b>Wrong Answer: </b></td>
              <td style="padding-left:5px;"><? echo testsByProblemId("Wrong Answer", $id); ?></td>
          </tr>
          <tr>
              <td style="padding-left:5px;"><b>Time Limit Exceeded: </b></td>
              <td style="padding-left:5px;"><? echo testsByProblemId("Time Limit Exceeded", $id); ?></td>
          </tr>
          <tr>
              <td style="padding-left:5px;"><b>Memory Limit Exceeded</b></td>
              <td style="padding-left:5px;"><? echo testsByProblemId("Memory Limit Exceeded", $id); ?></td>
          </tr>
          <tr>
              <td style="padding-left:5px;"><b>Output Limit Exceeded</b></td>
              <td style="padding-left:5px;"><? echo testsByProblemId("Output Limit Exceeded", $id); ?></td>
          </tr>
          <tr>
              <td style="padding-left:5px;"><b>Compilation Error:</b></td>
              <td style="padding-left:5px;"><? echo testsByProblemId("Compilation Error", $id); ?></td>
          </tr>
      </tbody>
  </table>

   <br/>
</body>
</html>